<script setup lang="ts" name="DashBoard">
import { ref, getCurrentInstance, onMounted, onUnmounted } from 'vue';
import type { ComponentInternalInstance } from 'vue';
// 引入webSocket的hooks
import useWebSocket from '@/hooks/useWebSocketErp';
// 引入获取当前天气钩子
import useWeather from '@/hooks/useWeather';
// 引入获取当前时间钩子
import useTimes from '@/hooks/useTimes';
import CenterComponent from '@/components/CenterComponent.vue';


// const { socketData } = useWebSocket();
const { tem, wea } = useWeather();
const { nowTime } = useTimes();

// proxy 相当于vue2 的this
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const centerRef = ref<InstanceType<typeof CenterComponent> | null>(null);


</script>

<template>
  <div class="content">
    <div class="title">
      <div class="titleLeft">{{ proxy?.$parseTime(nowTime, 'YYYY-MM-DD dddd HH:mm:ss') }}</div>
      <div class="titleStore">{{ centerRef?.supplierInfo?.name }}</div>
      <div class="timeNow">郑州天气：{{ wea }} {{ tem }}°C</div>
    </div>
    <div class="bottom">
      <div class="left">
        <div class="pieChart">
          <div>
            <h2>供应商品占比</h2>
          </div>
          <!-- 品类销售 -->
          <SuppliedGoods></SuppliedGoods>
        </div>
        <div class="goodsChart">
          <div>
            <h2>近一周门店商品销售排名</h2>
          </div>
          <!-- 商品排行 -->
          <SaleRank></SaleRank>
        </div>
      </div>
      <div class="center">
        <div class="bgCenter">
          <CenterComponent ref="centerRef"></CenterComponent>
        </div>
        <div class="tokenBgc">
          <div class="tokenTitle">
            <h2>商品实时交易轮播</h2>
          </div>
          <!-- 通证走势 -->
          <GoodsTransaction></GoodsTransaction>
        </div>
      </div>
      <div class="right">
        <div class="moneyChart">
          <div class="tokenTitle">
            <h2>近七日已收货订单金额</h2>
          </div>
          <OrderAmount></OrderAmount>
        </div>
        <div class="msgChart">
          <div class="tokenTitle">
            <h2>采购订单实时轮播</h2>
          </div>
          <ProcureOrder></ProcureOrder>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.content {
  box-sizing: border-box;
  /* background-color: #070c2a; */
  background: url(../assets/imgs/bgImg.png) no-repeat center 0px;
  background-size: contain;
  padding: 0;
  width: 1920px;
  height: 1080px;
  margin: 0;

  .title {
    width: 100%;
    height: 60px;
    background: url(../assets/imgs/title_bg.png) no-repeat center;
    background-size: contain;
    display: flex;

    .titleLeft {
      width: 33%;
      box-sizing: border-box;
      display: inline-block;
      font-size: 16px;
      color: #00a3ff;
      padding-top: 28px;
      padding-left: 375px;
    }

    .titleStore {
      width: 33%;
      text-align: center;
      margin: 0 auto;
      display: inline-block;
      font-size: 26px;
      padding-top: 10px;
      font-weight: bold;
      color: #eaf1fe;
      text-shadow: 0px 5px 8px rgba(6, 24, 60, 0.14);
      background: linear-gradient(0deg, #2fa4ee 0%, #ffffff 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .timeNow {
      width: 33%;
      box-sizing: border-box;
      display: inline-block;
      font-size: 16px;
      color: #00a3ff;
      padding-top: 28px;
      padding-left: 60px;
    }
  }

  .bottom {
    width: 100%;
    /* height: 100%; */
    display: flex;
    padding: 30px;
    /* padding-top: 0.0521rem; */
    justify-content: space-between;
    color: aliceblue;

    .left {
      width: 563px;

      /* margin-right: .1563rem; */
      .pieChart {
        margin-bottom: 30px;
        width: 563px;
        height: 323px;
        background: url(../assets/imgs/left_one.png) no-repeat center 0px;
        background-size: contain;

        h2 {
          font-size: 20px;
          font-weight: bold;
          padding: 10px 0 0 20px;
        }
      }

      .goodsChart {
        width: 563px;
        height: 596px;
        background: url(../assets/imgs/left_two.png) no-repeat center 0px;
        background-size: contain;

        h2 {
          font-size: 20px;
          font-weight: bold;
          padding: 10px 0 0 20px;
        }

      }
    }

    .center {
      flex: 1;
      position: relative;

      .bgCenter {
        width: 693px;
        height: 693px;
        background-color: RGBA(4, 7, 69, 1);
        margin: 0 auto;
      }

      .tokenBgc {
        z-index: 999;
        position: absolute;
        /* padding: .1042rem .1563rem; */
        bottom: 0;
        margin: 0 30px;
        width: 670px;
        height: 500px;
        background: url(../assets/imgs/tokenBgc.png) no-repeat center;
        background-size: 100% 500px;

        h2 {
          font-size: 20px;
          font-weight: bold;
          padding: 10px 0 0 20px;
        }
      }
    }

    .right {
      width: 563px;

      .moneyChart {
        margin-bottom: 30px;
        width: 563px;
        height: 323px;
        background: url(../assets/imgs/left_one.png) no-repeat center 0px;
        background-size: contain;

        h2 {
          font-size: 20px;
          font-weight: bold;
          padding: 10px 0 0 20px;
        }
      }

      .msgChart {
        width: 563px;
        height: 596px;
        background: url(../assets/imgs/left_two.png) no-repeat center 0px;
        background-size: contain;

        h2 {
          font-size: 20px;
          font-weight: bold;
          padding: 10px 0 0 20px;
        }
      }
    }
  }
}
</style>